use std::io::ErrorKind;

use aspect_msgqueue::MsgSummary;
use thiserror::Error;

/// Errors involved in reading/writing mailboxes.
#[derive(Debug, Error)]
pub enum MbError {
    #[error("batch submitted was too large")]
    BatchTooLarge,

    #[error("message already received ({0:?})")]
    MsgAlreadyReceived(MsgSummary),

    #[error("message idx {0} too old")]
    MsgTooOld(u64),

    #[error("network temporarily inaccessible")]
    NetworkInaccessible,

    /// This is if the network is accessible but the remote isn't, for some
    /// reason.
    #[error("remote temporarily inaccessible")]
    RemoteInaccessible,

    #[error("io: {0}")]
    Io(ErrorKind),

    #[error("not yet implemented")]
    Unimplemented,
}

pub type MbResult<T> = Result<T, MbError>;
